﻿/*****************************************介绍*****************************************
 * 作者：User
 * 创建时间：2025-06-10 14:21:06
 * 功能：语言适配处理
**************************************************************************************/

using Game.Framework;
using UnityEngine;
using UnityEngine.UI;

[RequireComponent(typeof(Text))]
public class LanguageHandle : MonoBehaviour
{
    private Text m_Text;
    private string m_DefaultKey;

    private void Awake()
    {
        m_Text = GetComponent<Text>();
        if (!m_Text)
        {
            LogManager.LogWarning("Can not find Text component!!", "LanguageHandle");
            return;
        }
        m_DefaultKey = m_Text.text;
    }

    private void OnEnable()
    {
        if (string.IsNullOrEmpty(m_DefaultKey)) return;
        m_Text.text = BaseDataMgr.Instance.GetLanguageValue(m_DefaultKey);
    }
}